//
//  PublicView.swift
//  Example
//
//  Created by xx on 2025/3/17.
//

import UIKit
import FastSwiftSDK

enum PublicButtonStyle{
    case backgroundColor
    case borderColor
}

class PublicView: UIView {
    
    // MARK: - 公共样式按钮
    static func button(title:String,style:PublicButtonStyle,callBack:@escaping FastVoidBlock) ->FastButton{
        let btn =  FastButton.init(title: title,color: .white);
        if style == .backgroundColor{
            btn.titleColor = .white
            btn.backgroundColor = themeColor
        }else if style == .borderColor{
            btn.titleColor = themeColor
            btn.border(color: themeColor, width: 1)
        }
        btn.cornerRadius = 5
        btn.click = callBack
        
        return  btn
    }
    
}

extension FastButton{
    func setStyle(_ style:PublicButtonStyle){
        if style == .backgroundColor{
            self.titleColor = .white
            self.backgroundColor = themeColor
        }else if style == .borderColor{
            self.backgroundColor = .clear
            self.titleColor = themeColor
            self.border(color: themeColor, width: 1)
        }
    }
}
